Conversation
nahjjun
requested changes
Jan 23, 2026
Member
nahjjun
left a comment
There was a problem hiding this comment.
전체적으로 N+1 문제만 해결하면 될 것 같습니다!! 코드 수정하느라 고생하셨습니다!!!
Comment on lines
178
to
204
| .findBySenderAndStatus(sender, FriendRequestStatus.PENDING) | ||
| .stream() | ||
| .map(req -> FriendRequestListResDto.builder() | ||
| .requestId(req.getId()) | ||
| .userId(req.getReceiver().getId()) | ||
| .nickname(req.getReceiver().getNickname()) | ||
| .requestedAt(req.getCreatedAt()) | ||
| .build() | ||
| ) | ||
| .map(req -> { | ||
| User receiver = req.getReceiver(); |
Member
There was a problem hiding this comment.
FriendRequestRepository의 findBySenderAndStatus() 함수에서 JPQL로 Fetch Join으로 Receiver도 한번에 가져오는 것이 좋을 것 같습니다.
현재 구조에서는 매 FriendRequest에 연결되어있는 Receiver를 Lazy Loading으로 매번 쿼리문을 가져오기 때문에 n+1 문제가 우려됩니다. 해당 부분 수정해주시면 성능적으로 이점이 있을 것 같습니다!
Comment on lines
224
to
227
| List<FriendResDto> friends = friendRepository.findByUser(user) | ||
| .stream() | ||
| .map(friend -> FriendResDto.builder() | ||
| .friendId(friend.getFriend().getId()) | ||
| .nickname(friend.getFriend().getNickname()) | ||
| .build() | ||
| ) | ||
| .map(friend -> { | ||
| var friendUser = friend.getFriend(); |
Member
There was a problem hiding this comment.
이 부분도 위에서 언급한 것과 마찬가지로, findByUser 함수에서 Friend 엔티티도 Fetch Join으로 가져와야 N+1 문제가 생기지 않을 것 같습니다!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#️⃣연관된 이슈
📝작업 내용
📝 기타 참고사항